"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var vue_1 = require("vue");
var ant_design_vue_1 = require("ant-design-vue");
var space_1 = require("../../constant/space");
var spaceUserController_ts_1 = require("@/api/spaceUserController.ts");
var dayjs_1 = __importDefault(require("dayjs"));
var props = defineProps();
var columns = [
    {
        title: '用户',
        dataIndex: 'userInfo',
    },
    {
        title: '角色',
        dataIndex: 'spaceRole',
    },
    {
        title: '创建时间',
        dataIndex: 'createTime',
    },
    {
        title: '操作',
        key: 'action',
    },
];
// 定义数据
var dataList = (0, vue_1.ref)([]);
// 获取数据
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
    var spaceId, res;
    var _a;
    return __generator(this, function (_b) {
        switch (_b.label) {
            case 0:
                spaceId = props.id;
                if (!spaceId) {
                    return [2 /*return*/];
                }
                return [4 /*yield*/, (0, spaceUserController_ts_1.listSpaceUserUsingPost)({
                        spaceId: spaceId,
                    })];
            case 1:
                res = _b.sent();
                if (res.data.code === 0 && res.data.data) {
                    dataList.value = (_a = res.data.data) !== null && _a !== void 0 ? _a : [];
                }
                else {
                    ant_design_vue_1.message.error('获取数据失败，' + res.data.message);
                }
                return [2 /*return*/];
        }
    });
}); };
// 页面加载时获取数据，请求一次
(0, vue_1.onMounted)(function () {
    fetchData();
});
// 添加成员表单
var formData = (0, vue_1.reactive)({});
// 创建成员
var handleSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
    var spaceId, res;
    return __generator(this, function (_a) {
        switch (_a.label) {
            case 0:
                spaceId = props.id;
                if (!spaceId) {
                    return [2 /*return*/];
                }
                return [4 /*yield*/, (0, spaceUserController_ts_1.addSpaceUserUsingPost)(__assign({ spaceId: spaceId }, formData))];
            case 1:
                res = _a.sent();
                if (res.data.code === 0) {
                    ant_design_vue_1.message.success('添加成功');
                    // 刷新数据
                    fetchData();
                }
                else {
                    ant_design_vue_1.message.error('添加失败，' + res.data.message);
                }
                return [2 /*return*/];
        }
    });
}); };
// 编辑成员角色
var editSpaceRole = function (value, record) { return __awaiter(void 0, void 0, void 0, function () {
    var res;
    return __generator(this, function (_a) {
        switch (_a.label) {
            case 0: return [4 /*yield*/, (0, spaceUserController_ts_1.editSpaceUserUsingPost)({
                    id: record.id,
                    spaceRole: value,
                })];
            case 1:
                res = _a.sent();
                if (res.data.code === 0) {
                    ant_design_vue_1.message.success('修改成功');
                }
                else {
                    ant_design_vue_1.message.error('修改失败，' + res.data.message);
                }
                return [2 /*return*/];
        }
    });
}); };
// 删除数据
var doDelete = function (id) { return __awaiter(void 0, void 0, void 0, function () {
    var res;
    return __generator(this, function (_a) {
        switch (_a.label) {
            case 0:
                if (!id) {
                    return [2 /*return*/];
                }
                return [4 /*yield*/, (0, spaceUserController_ts_1.deleteSpaceUserUsingPost)({ id: id })];
            case 1:
                res = _a.sent();
                if (res.data.code === 0) {
                    ant_design_vue_1.message.success('删除成功');
                    // 刷新数据
                    fetchData();
                }
                else {
                    ant_design_vue_1.message.error('删除失败');
                }
                return [2 /*return*/];
        }
    });
}); }; /* PartiallyEnd: #3632/scriptSetup.vue */
function __VLS_template() {
    var _a, _b, _c;
    var __VLS_ctx = {};
    var __VLS_components;
    var __VLS_directives;
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
        id: ("spaceManagePage"),
    });
    var __VLS_0 = {}.AFlex;
    /** @type { [typeof __VLS_components.AFlex, typeof __VLS_components.aFlex, typeof __VLS_components.AFlex, typeof __VLS_components.aFlex, ] } */ ;
    // @ts-ignore
    var __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({
        justify: ("space-between"),
    }));
    var __VLS_2 = __VLS_1.apply(void 0, __spreadArray([{
            justify: ("space-between"),
        }], __VLS_functionalComponentArgsRest(__VLS_1), false));
    __VLS_elementAsFunction(__VLS_intrinsicElements.h2, __VLS_intrinsicElements.h2)({});
    var __VLS_6 = {}.ASpace;
    /** @type { [typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, ] } */ ;
    // @ts-ignore
    var __VLS_7 = __VLS_asFunctionalComponent(__VLS_6, new __VLS_6({}));
    var __VLS_8 = __VLS_7.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_7), false));
    var __VLS_12 = {}.AButton;
    /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
    // @ts-ignore
    var __VLS_13 = __VLS_asFunctionalComponent(__VLS_12, new __VLS_12({
        type: ("primary"),
        href: ("/add_space"),
        target: ("_blank"),
    }));
    var __VLS_14 = __VLS_13.apply(void 0, __spreadArray([{
            type: ("primary"),
            href: ("/add_space"),
            target: ("_blank"),
        }], __VLS_functionalComponentArgsRest(__VLS_13), false));
    __VLS_17.slots.default;
    var __VLS_17;
    var __VLS_18 = {}.AButton;
    /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
    // @ts-ignore
    var __VLS_19 = __VLS_asFunctionalComponent(__VLS_18, new __VLS_18({
        type: ("primary"),
        ghost: (true),
        href: ("/space_analyze?queryPublic=1"),
        target: ("_blank"),
    }));
    var __VLS_20 = __VLS_19.apply(void 0, __spreadArray([{
            type: ("primary"),
            ghost: (true),
            href: ("/space_analyze?queryPublic=1"),
            target: ("_blank"),
        }], __VLS_functionalComponentArgsRest(__VLS_19), false));
    __VLS_23.slots.default;
    var __VLS_23;
    var __VLS_24 = {}.AButton;
    /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
    // @ts-ignore
    var __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24({
        type: ("primary"),
        ghost: (true),
        href: ("/space_analyze?queryAll=1"),
        target: ("_blank"),
    }));
    var __VLS_26 = __VLS_25.apply(void 0, __spreadArray([{
            type: ("primary"),
            ghost: (true),
            href: ("/space_analyze?queryAll=1"),
            target: ("_blank"),
        }], __VLS_functionalComponentArgsRest(__VLS_25), false));
    __VLS_29.slots.default;
    var __VLS_29;
    __VLS_11.slots.default;
    var __VLS_11;
    __VLS_5.slots.default;
    var __VLS_5;
    __VLS_elementAsFunction(__VLS_intrinsicElements.div)(__assign({ style: ({}) }));
    var __VLS_30 = {}.AForm;
    /** @type { [typeof __VLS_components.AForm, typeof __VLS_components.aForm, typeof __VLS_components.AForm, typeof __VLS_components.aForm, ] } */ ;
    // @ts-ignore
    var __VLS_31 = __VLS_asFunctionalComponent(__VLS_30, new __VLS_30(__assign({ 'onFinish': {} }, { layout: ("inline"), model: ((__VLS_ctx.formData)) })));
    var __VLS_32 = __VLS_31.apply(void 0, __spreadArray([__assign({ 'onFinish': {} }, { layout: ("inline"), model: ((__VLS_ctx.formData)) })], __VLS_functionalComponentArgsRest(__VLS_31), false));
    var __VLS_36;
    var __VLS_37 = {
        onFinish: (__VLS_ctx.handleSubmit)
    };
    var __VLS_33;
    var __VLS_34;
    var __VLS_38 = {}.AFormItem;
    /** @type { [typeof __VLS_components.AFormItem, typeof __VLS_components.aFormItem, typeof __VLS_components.AFormItem, typeof __VLS_components.aFormItem, ] } */ ;
    // @ts-ignore
    var __VLS_39 = __VLS_asFunctionalComponent(__VLS_38, new __VLS_38({
        label: ("用户 id"),
        name: ("userId"),
    }));
    var __VLS_40 = __VLS_39.apply(void 0, __spreadArray([{
            label: ("用户 id"),
            name: ("userId"),
        }], __VLS_functionalComponentArgsRest(__VLS_39), false));
    var __VLS_44 = {}.AInput;
    /** @type { [typeof __VLS_components.AInput, typeof __VLS_components.aInput, ] } */ ;
    // @ts-ignore
    var __VLS_45 = __VLS_asFunctionalComponent(__VLS_44, new __VLS_44({
        value: ((__VLS_ctx.formData.userId)),
        placeholder: ("请输入用户 id"),
        allowClear: (true),
    }));
    var __VLS_46 = __VLS_45.apply(void 0, __spreadArray([{
            value: ((__VLS_ctx.formData.userId)),
            placeholder: ("请输入用户 id"),
            allowClear: (true),
        }], __VLS_functionalComponentArgsRest(__VLS_45), false));
    __VLS_43.slots.default;
    var __VLS_43;
    var __VLS_50 = {}.AFormItem;
    /** @type { [typeof __VLS_components.AFormItem, typeof __VLS_components.aFormItem, typeof __VLS_components.AFormItem, typeof __VLS_components.aFormItem, ] } */ ;
    // @ts-ignore
    var __VLS_51 = __VLS_asFunctionalComponent(__VLS_50, new __VLS_50({}));
    var __VLS_52 = __VLS_51.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_51), false));
    var __VLS_56 = {}.AButton;
    /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
    // @ts-ignore
    var __VLS_57 = __VLS_asFunctionalComponent(__VLS_56, new __VLS_56({
        type: ("primary"),
        htmlType: ("submit"),
    }));
    var __VLS_58 = __VLS_57.apply(void 0, __spreadArray([{
            type: ("primary"),
            htmlType: ("submit"),
        }], __VLS_functionalComponentArgsRest(__VLS_57), false));
    __VLS_61.slots.default;
    var __VLS_61;
    __VLS_55.slots.default;
    var __VLS_55;
    __VLS_35.slots.default;
    var __VLS_35;
    __VLS_elementAsFunction(__VLS_intrinsicElements.div)(__assign({ style: ({}) }));
    var __VLS_62 = {}.ATable;
    /** @type { [typeof __VLS_components.ATable, typeof __VLS_components.aTable, typeof __VLS_components.ATable, typeof __VLS_components.aTable, ] } */ ;
    // @ts-ignore
    var __VLS_63 = __VLS_asFunctionalComponent(__VLS_62, new __VLS_62({
        columns: ((__VLS_ctx.columns)),
        dataSource: ((__VLS_ctx.dataList)),
    }));
    var __VLS_64 = __VLS_63.apply(void 0, __spreadArray([{
            columns: ((__VLS_ctx.columns)),
            dataSource: ((__VLS_ctx.dataList)),
        }], __VLS_functionalComponentArgsRest(__VLS_63), false));
    __VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
    {
        var __VLS_thisSlot = __VLS_67.slots.bodyCell;
        var _d = __VLS_getSlotParams(__VLS_thisSlot)[0], column_1 = _d.column, record_1 = _d.record;
        if (column_1.dataIndex === 'userInfo') {
            var __VLS_68 = {}.ASpace;
            /** @type { [typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, ] } */ ;
            // @ts-ignore
            var __VLS_69 = __VLS_asFunctionalComponent(__VLS_68, new __VLS_68({}));
            var __VLS_70 = __VLS_69.apply(void 0, __spreadArray([{}], __VLS_functionalComponentArgsRest(__VLS_69), false));
            var __VLS_74 = {}.AAvatar;
            /** @type { [typeof __VLS_components.AAvatar, typeof __VLS_components.aAvatar, ] } */ ;
            // @ts-ignore
            var __VLS_75 = __VLS_asFunctionalComponent(__VLS_74, new __VLS_74({
                src: (((_a = record_1.user) === null || _a === void 0 ? void 0 : _a.userAvatar)),
            }));
            var __VLS_76 = __VLS_75.apply(void 0, __spreadArray([{
                    src: (((_b = record_1.user) === null || _b === void 0 ? void 0 : _b.userAvatar)),
                }], __VLS_functionalComponentArgsRest(__VLS_75), false));
            ((_c = record_1.user) === null || _c === void 0 ? void 0 : _c.userName);
            __VLS_73.slots.default;
            var __VLS_73;
        }
        if (column_1.dataIndex === 'spaceRole') {
            var __VLS_80 = {}.ASelect;
            /** @type { [typeof __VLS_components.ASelect, typeof __VLS_components.aSelect, ] } */ ;
            // @ts-ignore
            var __VLS_81 = __VLS_asFunctionalComponent(__VLS_80, new __VLS_80(__assign({ 'onChange': {} }, { value: ((record_1.spaceRole)), options: ((__VLS_ctx.SPACE_ROLE_OPTIONS)) })));
            var __VLS_82 = __VLS_81.apply(void 0, __spreadArray([__assign({ 'onChange': {} }, { value: ((record_1.spaceRole)), options: ((__VLS_ctx.SPACE_ROLE_OPTIONS)) })], __VLS_functionalComponentArgsRest(__VLS_81), false));
            var __VLS_86 = void 0;
            var __VLS_87 = {
                onChange: (function (value) { return __VLS_ctx.editSpaceRole(value, record_1); })
            };
            var __VLS_83 = void 0;
            var __VLS_84 = void 0;
            var __VLS_85;
        }
        else if (column_1.dataIndex === 'createTime') {
            (__VLS_ctx.dayjs(record_1.createTime).format('YYYY-MM-DD HH:mm:ss'));
        }
        else if (column_1.key === 'action') {
            var __VLS_88 = {}.ASpace;
            /** @type { [typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, ] } */ ;
            // @ts-ignore
            var __VLS_89 = __VLS_asFunctionalComponent(__VLS_88, new __VLS_88({
                wrap: (true),
            }));
            var __VLS_90 = __VLS_89.apply(void 0, __spreadArray([{
                    wrap: (true),
                }], __VLS_functionalComponentArgsRest(__VLS_89), false));
            var __VLS_94 = {}.AButton;
            /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
            // @ts-ignore
            var __VLS_95 = __VLS_asFunctionalComponent(__VLS_94, new __VLS_94(__assign({ 'onClick': {} }, { type: ("link"), danger: (true) })));
            var __VLS_96 = __VLS_95.apply(void 0, __spreadArray([__assign({ 'onClick': {} }, { type: ("link"), danger: (true) })], __VLS_functionalComponentArgsRest(__VLS_95), false));
            var __VLS_100 = void 0;
            var __VLS_101 = {
                onClick: function () {
                    var _a = [];
                    for (var _i = 0; _i < arguments.length; _i++) {
                        _a[_i] = arguments[_i];
                    }
                    var $event = _a[0];
                    if (!(!((column_1.dataIndex === 'spaceRole'))))
                        return;
                    if (!(!((column_1.dataIndex === 'createTime'))))
                        return;
                    if (!((column_1.key === 'action')))
                        return;
                    __VLS_ctx.doDelete(record_1.id);
                }
            };
            var __VLS_97 = void 0;
            var __VLS_98 = void 0;
            __VLS_99.slots.default;
            var __VLS_99;
            __VLS_93.slots.default;
            var __VLS_93;
        }
    }
    var __VLS_67;
    var __VLS_slots;
    var $slots;
    var __VLS_inheritedAttrs;
    var $attrs;
    var __VLS_refs = {};
    var $refs;
    var $el;
    return {
        attrs: {},
        slots: __VLS_slots,
        refs: $refs,
        rootEl: $el,
    };
}
;
var __VLS_self = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {
            SPACE_ROLE_OPTIONS: space_1.SPACE_ROLE_OPTIONS,
            dayjs: dayjs_1.default,
            columns: columns,
            dataList: dataList,
            formData: formData,
            handleSubmit: handleSubmit,
            editSpaceRole: editSpaceRole,
            doDelete: doDelete,
        };
    },
    __typeProps: {},
});
exports.default = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {};
    },
    __typeProps: {},
    __typeEl: {},
});
; /* PartiallyEnd: #4569/main.vue */
